public class isHuiWen {
    public static void main(String[] args) {
        System.out.println(isHuiWen("abbba"));
    }

    public static boolean isHuiWen(String str) {
        int left = 0, right = str.length() - 1;

        while(left <= right) {
            char a = str.charAt(left);
            char b = str.charAt(right);
            if(a != b) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
